#ifndef __UTILS_H_
#define __UTILS_H_

#include "vector.h"
#include <cmath>

static const float PI = 3.141542f;

struct Vertexf{
    float x;
    float y;

    Vertexf(){
    	this->x=0;
    	this->y=0;
    }

    Vertexf(float x,float y){
    	this->x=x;
    	this->y=y;
    }

	Vertexf(const Vector& vect){
		this->x=vect[0];
		this->y=vect[1];
	}

	operator Vector(){
		return Vector(x,y);
	}
};

struct Vertexi{
    int x;
    int y;

    Vertexi(){
    	this->x=0;
        this->y=0;
	}

	Vertexi(int x,int y){
    	this->x=x;
    	this->y=y;
	}

	Vertexi(const Vertexf& vertex){
    	this->x=(int)floor(vertex.x+0.5f);
    	this->y=(int)floor(vertex.y+0.5f);
	}
};


struct Polygon{
    Vertexf* list;
    unsigned int size;

    Polygon(){
    	this->list = NULL;
    	this->size = 0;
    }

	Polygon(Vertexf* list,unsigned int size){
		this->list = new Vertexf[size];
		memcpy(this->list,list,sizeof(Vertexf)*size);
		this->size = size;
	}

	~Polygon(){
		if(this->list)
			delete this->list;
	}
};

struct Colorf{
    float r;
    float g;
    float b;

    Colorf(float r,float g,float b){
    	this->r=r; this->g=g; this->b=b;
    }
};

struct Window{
    Vertexf topRight;
	Vertexf bottomLeft;

	Window()
		: topRight(600,600),bottomLeft(0,0){
	}

	void set(float top,float left,float right,float bottom){
		this->topRight.x = right;
		this->topRight.y = top;
		this->bottomLeft.x = left;
		this->bottomLeft.y = bottom;
	}
};

struct Viewport{
    Vertexi topRight;
	Vertexi bottomLeft;

	Viewport()
		: topRight(600,600),bottomLeft(0,0){
	}

	void set(int top,int left,int right,int bottom){
		this->topRight.x = right;
		this->topRight.y = top;
		this->bottomLeft.x = left;
		this->bottomLeft.y = bottom;
	}
};

#endif /* __UTILS_H_ */
